package me.tuyou.jvm.gc;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

//-verbose:gc -XX:+PrintGCDetails -XX:+PrintHeapAtGC -XX:+PrintGCApplicationStoppedTime -XX:+PrintGCApplicationConcurrentTime
//-Xloggc:gc.log

//-XX:+UseSerialGC
//-XX:+UseParNewGC
//-XX:+UseParallelGC
//-XX:+UseParallelOldGC
//-XX:+UseConcMarkSweepGC
//-XX:+UseG1GC

//-XX:ConcGCThreads
//-XX:G1HeapRegionSize
//-XX:G1HeapWastePercent

/**
 * 常量池满异常
 *
 * @author：涂有
 * @date 2017年6月28日 下午2:21:42
 */
public class GCTest {
    public static void main(String[] args) {
        ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(1);
        executor.scheduleAtFixedRate(new Runnable() {
            long preTime = System.currentTimeMillis();
            @Override
            public void run() {
                long cur = System.currentTimeMillis();
                System.out.println("间隔：" + (cur - preTime));
                preTime = cur;
            }
        }, 0, 1, TimeUnit.SECONDS);

        List<String> list = new ArrayList<>();
        int item = 0;
        while (true) {
            list.add(String.valueOf(item++).intern());
        }
    }
}
